/**
 * 
 */
package profile.report;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * @author ductrung.tran
 *
 */
public class StoreResultReport {

	private String store;
	
	private Map<String, MethodResultReport> methodResultReportMap = new HashMap<String, MethodResultReport>();

	public void setStore(String store) {
		this.store = store;
	}

	public String getStore() {
		return store;
	}

	public void addMethodResultReport(MethodResultReport methodResultReport) {
		methodResultReportMap.put(methodResultReport.getMethod(), methodResultReport);
	}

	public MethodResultReport getMethodResultReport(String method) {
		return methodResultReportMap.get(method);
	}
	
	public String toString(int level) {
		return shift(level) + store + "\n" + toStringMethodResultReport(level);
	}

	private String shift(int level) {
		StringBuilder builder = new StringBuilder();
		for (int i = 1; i <= level; i++) {
			builder.append("  ");
		}
		return builder.toString();
	}
	
	private String toStringMethodResultReport(int level) {
		StringBuilder builder = new StringBuilder();
		for (MethodResultReport methodResultReport : methodResultReportMap.values()) {
			builder.append(methodResultReport.toString(level+1)).append('\n');
		}
		return builder.toString();
	}
	
	public Collection<MethodResultReport> getMethodResultReports() {
		return methodResultReportMap.values();
	}
}
